from threading import Thread
from time import sleep
class Account:
    def __init__(self,money,name):
        self.money=money
        self.name=name



#模拟提款
class Drawing(Thread):
   def __init__(self, drawingNum: object, account: object) -> object:
      Thread.__init__(self)
      self.drawNum=drawingNum
      self.accout=account
      self.expenseTotal=0
def run(self):
    if self.account.money<self.drawingNum:
        return
    sleep(1)#判断堵塞，就是为了解决冲突发生问题
    self.account.money-=self.drawingNum
    self.accountTotal+=self.drawingNum
    print(f"账户：{self.account.name},余额是:{self.account.money}")
    print(f"账户：{self.account.name},总共取了：{self.expenseTotal}")



if __name__ == '__main__':
    a1=Account(10000,'guanyu')
    draw1=Drawing(10000,a1)
    draw2=Drawing(10000,a1)

    draw1.start()
    draw2.start()

